home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_01 / thomas / nextaft.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-31  |  436 b   |  15 lines

  1. Listing 4: The function nextafter
  2.  
  3. #pragma fenv_access on<R>
  4. #pragma fp_wide_function_parameters off /* default */<R>
  5. float nextrep(float x) { /* 32-bit IEEE value */<R>
  6.     fenv_t saved_env;<R>
  7. <R>
  8.     (void) feholdexcept(&saved_env);<R>
  9.     fesetround(FE_UPWARD); /* + will round up */<R>
  10.     x += 0x1.0p-149; /* add tiniest subnormal */<R>
  11.     fesetenv(&saved_env); /* restore rounding, flags */<R>
  12.     return x;<R>
  13. }
  14.  
  15.